#ifndef MAPWINDOW_H
#define MAPWINDOW_H

#include <QtGui>
#include <QList>
#include <boost/shared_ptr.hpp>
#include <qmapcontrol.h>

typedef boost::shared_ptr<qmapcontrol::LineString> LineStringMapPtr;
typedef boost::shared_ptr<qmapcontrol::Point> CirclePointMapPtr;
Q_DECLARE_METATYPE(CirclePointMapPtr)

using qmapcontrol::Geometry;

class MapWindow: public QDialog
{
    Q_OBJECT

public:
    MapWindow(QWidget* parent = 0);
    ~MapWindow();

    void addCirclePoint(CirclePointMapPtr circlePoint);
    void removeCirclePoint(CirclePointMapPtr circlePoint);

    void addLineString(LineStringMapPtr lineString,
                       CirclePointMapPtr fromPoint = CirclePointMapPtr(),
                       CirclePointMapPtr toPoint = CirclePointMapPtr());
    void removeLineString(LineStringMapPtr lineString);

    void removeAllGepmetry();

signals:
    void pinDroped(const QPointF coordinate);
    void circlePointClicked(CirclePointMapPtr point);

public slots:
    void setUsePin(bool usePin);
    void updateMap();

private slots:
    void processMouseEventCoordinate(const QMouseEvent* evnt, const QPointF coordinate);
    void geometryClicked(Geometry* geom, QPoint coord_px);

private:
    qmapcontrol::MapControl* mapControl;
    qmapcontrol::MapAdapter* mapAdapter;
    qmapcontrol::Layer* mainLayer;

    QCursor* pinCursor;

    bool isUsePin;

    QList<LineStringMapPtr> lineStringList;
    QList<CirclePointMapPtr> circlePointList;

    void initCommonUi();
    void addZoomButtons();

protected:
    void resizeEvent(QResizeEvent* event);
};

#endif
